<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no" />
  <title>新建文档</title>
  <!--标准mui.css-->
  <link rel="stylesheet" href="../css/mui.min.css" />
  <script src="../js/mui.min.js"></script>
  <!--App自定义的css-->
  <link rel="stylesheet" type="text/css" href="../css/app.css" />
  <script src="../js/vue.js"></script>
  <script src="../js/jquery-3.6.0.min.js"></script>
  <script src="../js/vconsole.min.js"></script>
  <script src="../js/sm2.js"></script>
  <script src="../js/sm3.js"></script>
  <script src="../js/feedback.js"></script>
  <script src="../js/clipboard.js"></script>
  <script src="../js/flexible.js"></script>
  <script src="../wx/uap.js"></script>
  <script src="./text.js" type="text/javascript"></script>
  <style>
    .trainTicketstitle {
      background-color: #ffffff;
      /* background-image: linear-gradient(to right,
          rgb(13, 121, 131),
          rgb(25, 179, 182)); */
      padding: 0.3rem 0.2rem;
      color: #1e3754;
      height: 1rem;
      font-size: 0.35rem;
      border-bottom: 1px solid rgba(11, 66, 72, 0.05);
      /* box-shadow: 0px 8px 8px rgba(4, 124, 137, 0.05); */
    }

    #app {
      background-color: #ffffff;
    }

    .mui-btn-blue,
    .mui-btn-primary,
    input[type="submit"] {
      background-color: rgb(25, 179, 182);
      color: #fff;
      border: 1px solid rgb(25, 179, 182);
      border-radius: 4px;
      margin-right: 10px;
    }

    .left {
      text-align: center;
    }

    .left a {
      line-height: 0.5rem;
      color: #1e3754;
    }

    .left .left1 {
      position: absolute;
      left: 0.1rem;
      top: 0.25rem;
    }

    .left :nth-child(1) span {
      line-height: 0.5rem;
      color: #fff;
    }

    .left :nth-child(2) span {
      line-height: 0.5rem;
      color: #fff;
    }

    .file-input {
      opacity: 0;
      height: 100%;
      width: 100%;
      z-index: 999;
      position: absolute;
      left: 0;
      top: 0;
    }

    .top {
      height: 4.5rem;
      width: 100%;
      box-sizing: border-box;
      font-size: 0.3rem;
      position: relative;
      border-radius: 10px;
      margin-bottom: 0.3rem;
      position: relative;
      margin-top: 0.6rem;
    }

    .mui-content {
      width: 100%;
      height: 100%;
      background-color: #ffffff;
    }

    .functionsif {
      display: flex;
      justify-content:space-around;
      flex-wrap: wrap;
      margin: 0 10px;
    }

    .single {
      width: 85px;
      height: 120px;
      background-color: rgba(236, 243, 255, 0.6);
      border-radius: 10px;
      text-align: center;
      padding: 20px 0;
      margin: 5px 0;
      font-size: 12px;
    }
  </style>
</head>

<body>
  <div id="app">
    <div class="is-loading">
      <div class="curtain">
        <div class="loadingBgc">
          <div class="loader"></div>
        </div>
      </div>
    </div>
    <div class="trainTickets">
      <div class="trainTicketstitle">
        <div class="arrow clearfix">
          <div class="left">
            <span class="left1" @click="home">
              <a class="
                    mui-action-back mui-icon mui-icon-left-nav mui-pull-left
                  "></a>
            </span>
            <span style="font-weight: 600">新建文档</span>
          </div>
        </div>
      </div>
      <div class="mui-content">
        <div style="padding: 15px 15px;">
          <p>请选择新建的文档类型</p>
        </div>
        <div class="functionsif">
          <div class="single" v-for="(item, index) in functionsifList" :key="index" @click="searchFile(index, item)">
            <div class="imgDiv">
              <img :src="item.imgSrc" alt="" class="imgSrc" />
            </div>
            <span class="name">{{ item.name }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
  <script>
    new Vue({
      el: "#app",
      data() {
        return {
          
          front: "",
          back: "",
          active: 1,
          isflageIOX: true,
            timestamp: "", //时间戳
          accesstoken: "", //token
          flag: false,
          // Excel,Word,PPT     ,TXT,PDF
          functionsifList: [
            {
              id: 1,
              name: "新建Word",
              imgSrc: "../image/newDocument.png",
              acceptType: "image/png",
              fileType: 'Word',
            },
            {
              id: 2,
              name: "新建Excel",
              imgSrc: "../image/newDocument1.png",
              acceptType: "image/png",
              fileType: 'Excel',
            },
            {
              id: 3,
              name: "新建PPT",
              imgSrc: "../image/newDocument2.png",
              acceptType: "image/png",
              fileType: 'PPT',
            },
          ],
        };
      },
      created() {
        this.compatibleInput();
      },
      methods: {
        // 判断安卓还是ios
        compatibleInput() {
          //获取浏览器的userAgent,并转化为小写
          var ua = navigator.userAgent.toLowerCase();
          //判断是否是苹果手机，是则是true
          var isIos = ua.indexOf("iphone") != -1 || ua.indexOf("ipad") != -1;
          if (isIos) {
            this.isflageIOX = true;
          } else {
            this.isflageIOX = false;
          }
        },
        home() {
          $(location).attr("href", "Home.html");
        },
        // 按钮
        // $(location).attr("href", "NewBuilt.html");
        searchFile(index, item) {
          // this.show = true
          $(".curtain").css("display", "block");
          if (sessionStorage.getItem("iscp_port")) {
            iscp_port = sessionStorage.getItem("iscp_port");
          } else {
            iscp_port = "";
          }
          userId = sessionStorage.getItem("userId");

          let timestamp = new Date().getTime() + "";
          let data = {
            timestamp: timestamp,
            type: item.fileType,
            userId: userId,
          };
          console.log(data, 200);
          data = JSON.stringify(data);
          let sign = sm3(data);
          let AuthenticationSession = sessionStorage.getItem("Authentication");
          let URL = ''
          $.ajax({
            url: localUrlLink + iscp_port + '/document/record/documentCreate',
            type: "post",
            async: false, //是否同步，false表示同步请求
            dataType: "json",
            data: data,
            headers: {
              "Content-Type": "application/json;charset=UTF-8",
              Authentication: AuthenticationSession,
              sign: sign,
              timestamp: timestamp
            },
            success: (res, txt, xhr) => {
              console.log(res, "res272")
              $(".curtain").css("display", "none");
              console.log(res.resultValue, 274);
              console.log(sm3(res.resultValueStr) == xhr.getResponseHeader("sign"), 276);
              if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
                let Authentication = xhr.getResponseHeader("Authentication")
                if (res.code == 200) {
                  // this.show = true
                  var suffix = res.resultValue.suffix
                  var id = res.resultValue.id
                  var type = res.resultValue.type
                  // $(location).attr("href", "one.html")
                  // $(location).attr("href", "Home.html?emflag=emflag");
                  $(location).attr("href", "NewBuilt.html?one=one&suffix=" + suffix + "&id=" + id + "&type=" + type);
                } else {
                  mui.toast(res.resultValue, {
                    duration: 1000,
                    type: 'div'
                  })
                } 
              } else {
                mui.toast('完整性校验失败', {
                  duration: 1000,
                  type: 'div'
                })
              }
            },
            error: (e) => {
              $(".curtain").css("display", "none");
              mui.toast('请求异常,请稍后再试', {
                duration: 1000,
                type: 'div'
              })
            },
          });
        },
        //确定
        confirm() {
          console.log(this.updateName, 277);
          if (sessionStorage.getItem("iscp_port")) {
            iscp_port = sessionStorage.getItem("iscp_port");
          } else {
            iscp_port = "";
          }
          this.num += 1
          let timestamp = new Date().getTime() + "";
          let data = {
            timestamp: timestamp,
            id: this.id,
            updateName: this.updateName,
          };
          console.log(data, 200);
          data = JSON.stringify(data);
          let sign = sm3(data);
          let AuthenticationSession = sessionStorage.getItem("Authentication");
          let URL = ''
          $.ajax({
            url: localUrlLink + iscp_port + '/document/record/documentUpdate',
            type: "post",
            async: false, //是否同步，false表示同步请求
            dataType: "json",
            data: data,
            headers: {
              "Content-Type": "application/json;charset=UTF-8",
              Authentication: AuthenticationSession,
              sign: sign,
              timestamp: timestamp
            },
            success: (res, txt, xhr) => {
              console.log(res, "res")
              $(".curtain").css("display", "none");
              if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
                let Authentication = xhr.getResponseHeader("Authentication")
                if (res.code == 200) {
                  mui.toast('重命名成功', {
                    duration: 1000,
                    type: 'div'
                  })
                  this.num = 0
                  this.getList(0, '')
                } else{
                  mui.toast(res.resultValue, {
                    duration: 1000,
                    type: 'div'
                  })
                } 
              } else {
                mui.toast('完整性校验失败', {
                  duration: 1000,
                  type: 'div'
                })
              }
            },
            error: (e) => {
              $(".curtain").css("display", "none");
              mui.toast('请求异常,请稍后再试', {
                duration: 1000,
                type: 'div'
              })
            },
          });
        },
        // input限制输入
        handleInput() {
          // 过滤特殊字符、空格和表情包
          // this.updateName = this.updateName.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g, '');
          // 过滤特殊字符和表情包
          this.updateName = this.updateName.replace(/[\\/:*?"<>|？“”：*]/g, '');

          // 限制字符数
          if (this.updateName.length > 50) {
            this.updateName = this.updateName.slice(0, 50);
          }
        },
      },
    });
  </script>
</body>

</html>

<body></body>